package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import dominio.Contrato;
import dominio.Convenio;
import dominio.Coordinador;
import dominio.Desarrollador;
import dominio.Funcion;
import dominio.Integrante;
import dominio.Proyecto;

public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
        	 config.addAnnotatedClass(PersistentObject.class);
        	 config.addAnnotatedClass(dominio.Proyecto.class);
        	 config.addAnnotatedClass(dominio.Contrato.class);
        	 config.addAnnotatedClass(dominio.Convenio.class);
        	 config.addAnnotatedClass(dominio.Coordinador.class);
        	 config.addAnnotatedClass(dominio.Desarrollador.class);
        	 config.addAnnotatedClass(dominio.Funcion.class);
        	 config.addAnnotatedClass(dominio.Integrante.class);
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
  
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
